import {onMounted, reactive, ref} from "vue";

export default function useMousePosition() {
  // let x = ref<number>(0);
  // let y = ref<number>(0);
  interface XYType {
    x: number;
    y: number
  }

  let xyObj = reactive<XYType>({x: 0, y: 0})
  onMounted(() => {
    document.addEventListener('click', (event: MouseEvent) => {
      // console.log(event.pageX)//clientX
      // x.value = event.pageX;
      // y.value = event.pageY;
      xyObj.x = event.pageX;
      xyObj.y = event.pageY;
    })
  })
  // return {x, y}
  return xyObj
}
